home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 24
/
Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso
/
Aminet
/
gfx
/
show
/
GS510_data.lha
/
ghostscript
/
5.10
/
gs_fonts.ps
< prev
next >
Wrap
Text File
|
1997-12-28
|
28KB
|
913 lines
% Copyright (C) 1990, 1995, 1996, 1997 Aladdin Enterprises. All rights reserved.
%
% This file is part of Aladdin Ghostscript.
%
% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author
% or distributor accepts any responsibility for the consequences of using it,
% or for whether it serves any particular purpose or works at all, unless he
% or she says so in writing. Refer to the Aladdin Ghostscript Free Public
% License (the "License") for full details.
%
% Every copy of Aladdin Ghostscript must include a copy of the License,
% normally in a plain ASCII text file named PUBLIC. The License grants you
% the right to copy, modify and redistribute Aladdin Ghostscript, but only
% under certain conditions described in the License. Among other things, the
% License requires that the copyright notice and this notice be preserved on
% all copies.
% Font initialization and management code.
% Define the default font.
/defaultfontname /Courier def
% Define the name of the font map file.
/defaultfontmap (Fontmap) def
% ------ End of editable parameters ------ %
% If SUBSTFONT is defined, make it the default font.
/SUBSTFONT where { pop /defaultfontname /SUBSTFONT load def } if
% Define a reliable way of accessing FontDirectory in systemdict.
/.FontDirectory
{ //systemdict /FontDirectory get
} bind odef
% If DISKFONTS is true, we load individual CharStrings as they are needed.
% (This is intended primarily for machines with very small memories.)
% In this case, we define another dictionary, parallel to FontDirectory,
% that retains an open file for every font loaded.
/FontFileDirectory 10 dict def
% Define a temporary string for local use, since using =string
% interferes with some PostScript programs.
/.fonttempstring 128 string def
% Split up a search path into individual directories or files.
/.pathlist % <path> .pathlist <dir1|file1> ...
{ { dup length 0 eq { pop exit } if
.filenamelistseparator search not { exit } if
exch pop exch
}
loop
} bind def
% Load a font name -> font file name map.
userdict /Fontmap .FontDirectory maxlength dict put
/.loadFontmap % <file> .loadFontmap -
{ % We would like to simply execute .definefontmap as we read,
% but we have to maintain backward compatibility with an older
% specification that makes later entries override earlier.
50 dict exch
{ dup token not { closefile exit } if
% stack: <file> fontname
% This is a hack to get around the absurd habit of MS-DOS editors
% of adding an EOF character at the end of the file.
dup (\032) eq { pop closefile exit } if
1 index token not
{ (Fontmap entry for ) print dup =only
( has no associated file or alias name! Giving up.\n) print flush
{.loadFontmap} 0 get 1 .quit
} if
dup type dup /stringtype eq exch /nametype eq or not
{ (Fontmap entry for ) print 1 index =only
( has an invalid file or alias name! Giving up.\n) print flush
{.loadFontmap} 0 get 1 .quit
} if
% stack: dict file fontname filename|aliasname
% Read and pop tokens until a semicolon.
{ 2 index token not
{ (Fontmap entry for ) print 1 index =only
( ends prematurely! Giving up.\n) print flush
{.loadFontmap} 0 get 1 .quit
} if
dup /; eq { pop 3 index 3 1 roll .growput exit } if
pop
} loop
} loop
{ .definefontmap } forall
} bind def
% Add an entry in Fontmap. We redefine this if the Level 2
% resource machinery is loaded.
/.definefontmap % <fontname> <file|alias> .definefontmap -
{ % Since Fontmap is global, make sure the values are storable.
.currentglobal 3 1 roll true .setglobal
dup type /stringtype eq
{ dup .gcheck not { dup length string copy } if
}
if
Fontmap 3 -1 roll 2 copy .knownget
{ % Add an element to the end of the existing value,
% unless it's the same as the current last element.
mark exch aload pop counttomark 4 add -1 roll
2 copy eq { cleartomark pop pop } { ] readonly .growput } ifelse
}
{ % Make a new entry.
mark 4 -1 roll ] readonly .growput
}
ifelse .setglobal
} bind def
% Parse a font file just enough to find the FontName or FontType.
/.findfontvalue % <file> <key> .findfontvalue <value> true
% <file> <key> .findfontvalue false
% Closes the file in either case.
{ exch dup read not { -1 } if
2 copy unread 16#80 eq
{ dup (xxxxxx) readstring pop pop } % skip .PFB header
if
% Stack: key file
{ dup token not { false exit } if % end of file
dup /eexec eq { pop false exit } if % reached eexec section
dup /Subrs eq { pop false exit } if % Subrs without eexec
dup /CharStrings eq { pop false exit } if % CharStrings without eexec
dup 3 index eq
{ xcheck not { dup token exit } if } % found key
{ pop }
ifelse
} loop
% Stack: key file value true (or)
% Stack: key file false
dup { 4 } { 3 } ifelse -2 roll closefile pop
} bind def
/.findfontname
{ /FontName .findfontvalue
} bind def
% If there is no FONTPATH, try to get one from the environment.
NOFONTPATH { /FONTPATH () def } if
/FONTPATH where
{ pop }
{ /FONTPATH (GS_FONTPATH) getenv not { () } if def }
ifelse
FONTPATH length 0 eq { (%END FONTPATH) .skipeof } if
/FONTPATH [ FONTPATH .pathlist ] def
% Scan directories looking for plausible fonts. "Plausible" means that
% the file begins with %!PS-AdobeFont or %!FontType1, or with \200\001
% followed by four arbitrary bytes and then either of these strings.
% To speed up the search, we skip any file whose name appears in
% the Fontmap (with any extension and upper/lower case variation) already,
% and any file whose extension definitely indicates it is not a font.
%
% NOTE: The current implementation of this procedure is somewhat Unix/DOS-
% specific. It assumes that '/' and '\' are directory separators, and that
% the part of a file name following the last '.' is the extension.
%
/.lowerstring % <string> .lowerstring <lowerstring>
{ 0 1 2 index length 1 sub
{ 2 copy get dup 65 ge exch 90 le and
{ 2 copy 2 copy get 32 add put }
if pop
}
for
} bind def
/.splitfilename % <dir.../base.extn> .basename <base> <extn>
{ { (/) search { true } { (\\) search } ifelse
{ pop pop }
{ exit }
ifelse
}
loop
dup { (.) search { pop pop } { exit } ifelse } loop
2 copy eq
{ pop () }
{ exch dup length 2 index length 1 add sub 0 exch getinterval exch }
ifelse
% Following is debugging code.
% (*** Split => ) print 2 copy exch ==only ( ) print ==only
% ( ***\n) print flush
} bind def
/.scanfontdict 1 dict def % establish a binding
/.scanfontbegin
{ % Construct the table of all file names already in Fontmap.
currentglobal true setglobal
.scanfontdict dup maxlength Fontmap length 2 add .max .setmaxlength
Fontmap
{ exch pop
{ dup type /stringtype eq
{ .splitfilename pop .fonttempstring copy .lowerstring cvn
.scanfontdict exch true put
}
{ pop
}
ifelse
}
forall
}
forall
setglobal
} bind def
/.scanfontskip mark
% Strings are converted to names anyway, so....
/afm true
/bat true
/c true
/cmd true
/com true
/dll true
/doc true
/drv true
/exe true
/fon true
/fot true
/h true
/o true
/obj true
/pfm true
/pss true % Adobe Multiple Master font instances
/txt true
.dicttomark def
/.scan1fontstring 128 string def
/.scanfontheaders [(%!PS-Adobe*) (%!FontType*)] def
0 .scanfontheaders { length max } forall 6 add % extra for PFB header
/.scan1fontfirst exch string def
/.scanfontdir % <dirname> .scanfontdir -
{ currentglobal exch true setglobal
QUIET not { (Scanning ) print dup print ( for fonts...) print flush } if
(*) 2 copy .filenamedirseparator
dup (\\) eq { pop (\\\\) } if % double \ for pattern match
exch concatstrings concatstrings
0 0 0 4 -1 roll % found scanned files
{ % stack: <fontcount> <scancount> <filecount> <filename>
exch 1 add exch % increment filecount
dup .splitfilename .lowerstring
% stack: <fontcount> <scancount> <filecount+1> <filename>
% <BASE>